package com.rdxer.core.security;

import com.rdxer.service.AccountService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 检查权限的 service
 */
@Service("cks")
public class CheckService {

    Logger logger = LogManager.getLogger(CheckService.class.getName());

    @Autowired
    AccountService accountService;

    public boolean isAdmin() {

        logger.warn(AppUserDetails.getCurrent());

        AppUserDetails current = AppUserDetails.getCurrent();

        return current.isAdmin();
    }


    public boolean isSelf(Long id) {
        return AppUserDetails.getCurrent().account.getId().equals(id);
    }
}
